package com.company.test30.CharSoftware;

import javax.swing.*;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.PlainDocument;
import java.awt.*;

/**
 * Created by v on 16-12-5.
 */
public class ChatPanel extends JPanel {
    public JTextArea jtaInput=new JTextArea();
    public JLabel jlbInput=new JLabel("输入域");
    public JTextArea jtaShow=new JTextArea();
    public JLabel jlbShow=new JLabel("查看对话域");

    public boolean[] keys=new boolean[0xFFFF];

    public ChatPanel(){
        //先初初始化组件的字体
        Font font=new Font("微软雅黑",0,15);
        jtaInput.setFont(font);
        jlbInput.setFont(font);
        jtaShow.setFont(font);
        jlbShow.setFont(font);
        jtaShow.setEditable(false);

        //输入域初始化
        JPanel panel1=new JPanel();
        panel1.setLayout(new BorderLayout());
        panel1.add(jlbInput,BorderLayout.NORTH);
        panel1.add(new JScrollPane(jtaInput),BorderLayout.CENTER);

        //查看对话域初始化
        JPanel panel2=new JPanel();
        panel2.setLayout(new BorderLayout());
        panel2.add(jlbShow,BorderLayout.NORTH);
        panel2.add(new JScrollPane(jtaShow),BorderLayout.CENTER);

        //初始化applet
        GridBagLayout layout=new GridBagLayout();
        GridBagConstraints constraints=new GridBagConstraints();
        add(panel2);
        add(panel1);
        setLayout(layout);

        constraints.fill=GridBagConstraints.BOTH;
        constraints.weightx=1;
        constraints.weighty=1;
        constraints.gridwidth=0;
        layout.setConstraints(panel2,constraints);

        constraints.weighty=0.35;
        layout.setConstraints(panel1,constraints);
    }
}
